package com.huawei.appgallery.wishwall.ui.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.huawei.appgallery.foundation.store.bean.user.UserInfoListResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.BottomButton;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appgallery.wishwall.api.IWishWallReplyActivityProtocol;
import com.huawei.appgallery.wishwall.api.IWishWallReplyActivityResult;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallDetailContentCardBean;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallDetailReplyCardBean;
import com.huawei.appgallery.wishwall.ui.fragment.protocol.WishWallDetailFragmentProtocol;
import com.huawei.appgallery.wishwall.ui.fragment.protocol.WishWallDetailFragmentProtocol.Request;
import com.huawei.hmf.annotation.FragmentDefine;
import java.util.List;
import o.cfv;
import o.cfw;
import o.cgi;
import o.cih;
import o.BaseAlertDialog;
import o.BaseAlertDialog.a;
import o.ckt;
import o.BaseRequest;
import o.ddq.c;
import o.ddq.d;
import o.ddq.f;
import o.ddr;
import o.ddt;
import o.ddu;
import o.ddz;
import o.djl;
import o.ContentManager;
import o.epv;
import o.ActivityUtil;
import o.evk;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;

@FragmentDefine(alias = "wishwall.detail.fragment")
public class WishWallDetailFragment extends AppListFragment<WishWallDetailFragmentProtocol> implements OnClickListener {
    private BottomButton ˊ;
    private String ॱॱ;
    private WishWallDetailFragmentProtocol ᐝ;
    private djl ﾞ;
    private String ﾟ;

    public void ˏ(Bundle bundle) {
        super.ˏ(bundle);
    }

    public void ᐝʼ() {
        super.ᐝʼ();
        this.ᐝ = (WishWallDetailFragmentProtocol) ˆ();
        if (this.ᐝ != null && this.ᐝ.ॱ() != null) {
            this.ʼˊ = ((Request) this.ᐝ.ॱ()).ˎˎ();
        }
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        this.ˊ = (BottomButton) this.ॱˍ.findViewById(d.ˎˏ);
        this.ˊ.getLayoutParams().width = epv.ˎ(ॱˋ()) / 2;
        this.ˊ.setVisibility(8);
        this.ˊ.setOnClickListener(new ckt(this));
        return ˋ;
    }

    public int ᵎ() {
        return c.ˋॱ;
    }

    public boolean ﹳॱ() {
        return false;
    }

    public void ͺˎ() {
    }

    public cfv ˏ(String str, String str2, int i) {
        return cgi.ˏ(str, str2, i);
    }

    public void ˋ(TaskFragment taskFragment, List list) {
        super.ˋ(taskFragment, list);
    }

    public boolean ˊ(TaskFragment taskFragment, b bVar) {
        boolean ˊ = super.ˊ(taskFragment, bVar);
        this.ˊ.setVisibility(8);
        UserInfoListResponse userInfoListResponse = (UserInfoListResponse) bVar.ˋ;
        if (userInfoListResponse.getResponseCode() == 0 && userInfoListResponse.getRtnCode_() == 0) {
            WishWallDetailContentCardBean ˎ = ddz.ˏ().ˎ(this.י);
            if (ˎ != null) {
                this.ﾟ = ˎ.v_();
                this.ॱॱ = ˎ.ॱ();
                int ꓸ = ˎ.ꓸ();
                if (ꓸ == 1 || ꓸ == 0) {
                    this.ˊ.setVisibility(0);
                }
            }
        }
        ddz.ˏ().ˋ(this.י);
        return ˊ;
    }

    public void ˏ(int i, cih o_cih) {
        super.ˏ(i, o_cih);
        CardBean ˌ;
        if (i == 10001) {
            ˌ = o_cih.ˌ();
            if (ˌ instanceof WishWallDetailReplyCardBean) {
                ॱ((WishWallDetailReplyCardBean) ˌ);
            }
        } else if (i == 10002) {
            ˌ = o_cih.ˌ();
            if (ˌ instanceof WishWallDetailReplyCardBean) {
                ˊ((WishWallDetailReplyCardBean) ˌ);
            }
        }
    }

    private void ˊ(final WishWallDetailReplyCardBean wishWallDetailReplyCardBean) {
        final BaseAlertDialog ˋ = BaseAlertDialog.ˋ(ॱˋ(), null, ॱ(f.ˏॱ));
        ˋ.ॱ();
        ˋ.ˊ(new OnClickListener(this) {
            final /* synthetic */ WishWallDetailFragment ॱ;

            public void onClick(View view) {
                ˋ.ˏ();
                this.ॱ.ˎ(wishWallDetailReplyCardBean);
            }
        });
    }

    private void ॱ(final WishWallDetailReplyCardBean wishWallDetailReplyCardBean) {
        final BaseAlertDialog ˋ = BaseAlertDialog.ˋ(ॱˋ(), null, ॱ(f.ॱˊ));
        ˋ.ॱ();
        ˋ.ॱ(a.CONFIRM, ॱ(f.ॱॱ));
        ˋ.ˊ(new OnClickListener(this) {
            final /* synthetic */ WishWallDetailFragment ˊ;

            public void onClick(View view) {
                ˋ.ˏ();
                this.ˊ.ˋ(wishWallDetailReplyCardBean);
            }
        });
    }

    private void ˎ(final WishWallDetailReplyCardBean wishWallDetailReplyCardBean) {
        Object ᐝᐝ = wishWallDetailReplyCardBean.ᐝᐝ();
        if (TextUtils.isEmpty(ᐝᐝ)) {
            evk.ॱ(ContentManager.getInstant().getContext().getString(f.ॱˎ), 0).ˋ();
            return;
        }
        this.ﾞ = new djl(ॱˋ());
        this.ﾞ.setCanceledOnTouchOutside(false);
        this.ﾞ.ˋ(ॱ(f.ˏ));
        this.ﾞ.show();
        cfw.ˎ(new ddt(ᐝᐝ, this.ॱॱ), new IServerCallBack(this) {
            final /* synthetic */ WishWallDetailFragment ˊ;

            public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
            }

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                if (ActivityUtil.isAcitivtyNotValid(this.ˊ.ॱˋ())) {
                    ddu.ˊ.ˋ("WishWallDetailFragment", "activity has been finished, ignore best answer response");
                    return;
                }
                this.ˊ.ﾞ.dismiss();
                if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                    ddu.ˊ.ˋ("WishWallDetailFragment", "adopt best answer successfully!!!");
                    ddz.ˏ().ˋ(wishWallDetailReplyCardBean);
                    ddz.ˏ().ˊ(this.ˊ.י);
                    return;
                }
                ddu.ˊ.ˋ("WishWallDetailFragment", "adopt best answer failed!!!");
                evk.ॱ(ContentManager.getInstant().getContext().getString(f.ॱˎ), 0).ˋ();
            }
        });
    }

    private void ˋ(final WishWallDetailReplyCardBean wishWallDetailReplyCardBean) {
        Object ᐝᐝ = wishWallDetailReplyCardBean.ᐝᐝ();
        if (TextUtils.isEmpty(ᐝᐝ)) {
            evk.ॱ(ContentManager.getInstant().getContext().getString(f.ॱˎ), 0).ˋ();
            return;
        }
        this.ﾞ = new djl(ॱˋ());
        this.ﾞ.setCanceledOnTouchOutside(false);
        this.ﾞ.ˋ(ॱ(f.ˋॱ));
        this.ﾞ.show();
        cfw.ˎ(new ddr(ᐝᐝ), new IServerCallBack(this) {
            final /* synthetic */ WishWallDetailFragment ˏ;

            public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
            }

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                if (ActivityUtil.isAcitivtyNotValid(this.ˏ.ॱˋ())) {
                    ddu.ˊ.ˋ("WishWallDetailFragment", "activity has been finished, ignore delete reply response");
                    return;
                }
                this.ˏ.ﾞ.dismiss();
                if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                    ddu.ˊ.ˋ("WishWallDetailFragment", "delete reply successfully!!!");
                    ddz.ˏ().ˋ(this.ˏ.י, ((ddr) o_cvu).ॱ());
                    if (wishWallDetailReplyCardBean.ʽ()) {
                        this.ˏ.ˎͺ();
                        return;
                    }
                    return;
                }
                ddu.ˊ.ˋ("WishWallDetailFragment", "delete reply failed!!!");
                evk.ॱ(ContentManager.getInstant().getContext().getString(f.ॱˎ), 0).ˋ();
            }
        });
    }

    public void onClick(View view) {
        if (view.getId() == d.ˎˏ) {
            ˊʻ();
        }
    }

    private void ˊʻ() {
        fjb ˎ = fho.ˏ().ˋ("WishWall").ˎ("wish.wall.reply.activity");
        IWishWallReplyActivityProtocol iWishWallReplyActivityProtocol = (IWishWallReplyActivityProtocol) ˎ.ˊ();
        IWishWallReplyActivityProtocol.Request request = new IWishWallReplyActivityProtocol.Request();
        request.ˋ(this.ॱॱ);
        request.ˏ(this.ﾟ);
        iWishWallReplyActivityProtocol.ˎ(request);
        fiu.ˊ().ॱ(ॱˊ(), ˎ, new fjc<IWishWallReplyActivityResult>(this) {
            final /* synthetic */ WishWallDetailFragment ˊ;

            {
                this.ˊ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ˋ(i, (IWishWallReplyActivityResult) obj);
            }

            public void ˋ(int i, IWishWallReplyActivityResult iWishWallReplyActivityResult) {
                ddu.ˊ.ˋ("WishWallDetailFragment", "WishWallReplyActivity result:" + i);
                if (i == -1 && iWishWallReplyActivityResult != null && iWishWallReplyActivityResult.getHasReplied()) {
                    this.ˊ.ˎͺ();
                }
            }
        });
    }
}
